www.gusucode.com > 小波分析理论与Matlab 7实现 > 小波分析理论与Matlab 7实现/code/Ch16/examp16_7.m
%生成含噪斜波信号 N=1000; t=1:N; sig(1:500)=3*(1:500)/500; sig(501:N)=3; x=sig+randn(1,N); figure(1); plot(t,x,'LineWidth',2);xlabel('时间 t/s');ylabel('幅值 A'); %一维小波分解 [c,l] = wavedec(x,6,'db3'); %重构第1~6层逼近信号 a6 = wrcoef('a',c,l,'db3',6); a5 = wrcoef('a',c,l,'db3',5); a4 = wrcoef('a',c,l,'db3',4); a3 = wrcoef('a',c,l,'db3',3); a2 = wrcoef('a',c,l,'db3',2); a1 = wrcoef('a',c,l,'db3',1); %显示各层逼近信号 figure(2) subplot(6,1,1);plot(a6,'LineWidth',2);ylabel('a6'); subplot(6,1,2);plot(a5,'LineWidth',2);ylabel('a5'); subplot(6,1,3);plot(a4,'LineWidth',2);ylabel('a4'); subplot(6,1,4);plot(a3,'LineWidth',2);ylabel('a3'); subplot(6,1,5);plot(a2,'LineWidth',2);ylabel('a2'); subplot(6,1,6);plot(a1,'LineWidth',2);ylabel('a1'); xlabel('时间 t/s'); %重构第1~6层细节信号 d6 = wrcoef('d',c,l,'db3',6); d5 = wrcoef('d',c,l,'db3',5); d4 = wrcoef('d',c,l,'db3',4); d3 = wrcoef('d',c,l,'db3',3); d2 = wrcoef('d',c,l,'db3',2); d1 = wrcoef('d',c,l,'db3',1); %显示各层细节信号 figure(3) subplot(6,1,1);plot(d6,'LineWidth',2);ylabel('d6'); subplot(6,1,2);plot(d5,'LineWidth',2);ylabel('d5'); subplot(6,1,3);plot(d4,'LineWidth',2);ylabel('d4'); subplot(6,1,4);plot(d3,'LineWidth',2);ylabel('d3'); subplot(6,1,5);plot(d2,'LineWidth',2);ylabel('d2'); subplot(6,1,6);plot(d1,'LineWidth',2);ylabel('d1'); xlabel('时间 t/s');